package com.itxh.core.utils;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;

public class ReflectUtils {
    public static Object resolveValue(Object param, String parameterName) throws Exception{
        Class<?> aClass = param.getClass();
        Field field = aClass.getDeclaredField(parameterName);
        field.setAccessible(true);
        return field.get(param);
    }


    public static void setPropretyValue(Object result, String columnName, Object value) throws Exception{
        Class<?> aClass = result.getClass();
        Field field = aClass.getDeclaredField(columnName);
        field.setAccessible(true);
        field.set(result,value);
    }

    public static Object newInstance(Class resultType) throws Exception{
        Constructor constructor = resultType.getConstructor();
        return constructor.newInstance();
    }
}
